package com.yidong.tinydict;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.SearchView;

import com.squareup.okhttp.Call;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import com.squareup.picasso.Picasso;
import com.yidong.tinydict.Fragment.SentenceFragment;
import com.yidong.tinydict.Fragment.WordFragment;

import java.io.IOException;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button button=findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(MainActivity.this, WordFragment.class);
            }
        });
        Button button3=findViewById(R.id.button3);
        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(MainActivity.this,WordFragment.class);
            }
        });
    }

    public void getRequest(Context context, String requestUrl) {
        Context mContext = context;

        try {
            OkHttpClient client=new OkHttpClient();
            RequestBody mRequestBody=RequestBody.create(MediaType.parse("text/plain;chaset=utf-8;charset=utf-8");
            String url="http://192.168.129.100:8080/dingding/servlet/ListCarAervlet?userid=";
            Request .Builder mBulider=new Request.Builder();
            Request request=mBulider.post(mRequestBody).url(requestUrl).build();
            OkHttpClient mOkHttpClient = null;
           Call mCall=mOkHttpClient.newCall(request);
            mCall.enqueue(new Callback() {
                @Override
                public void onFailure(Request request, IOException arg1) {
                    
                }

                @Override
                public void onResponse(Response response) throws IOException {

                }

           //     @Override
                public void onResponse(Call arg0,Response arg1) throws IOException {
                       String s=arg1.body().string();
                       //orderList=JSON.parseArray();
                    Runnable runnable=new Runnable() {
                        @Override
                        public void run() {
                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException ex) {
                                ex.printStackTrace();
                            }
                        }
                    };
                }
            });
            
        }catch (Exception e){
            
        }
        //图片下载
        Picasso.with(context).load("http://open.iciba.com/?c=wiki");

        }


}